/**
 * @description 封装axios请求模块的仓库
 */

import {defineStore} from 'pinia' //引入pinia的创建函数方法

const useHttpStore =defineStore('http',{
    state:()=>({
        //正在等待的请求数量
        pendingNum:0,
        //请求总数
        requestSum:0,
        //是否正在请求
        isPedding:false,
    }),
    actions:{
        //添加等待请求
        addPendingNum(){
            this.pendingNum++
        },
        //删除等待请求
        deletePendingNum(){
            this.pendingNum--
        },
        //获取等待请求数量  
        getPendingNum(){
            return this.pendingNum
        },
        //获取请求数量
        getRequestSum(){
            return this.requestSum
        },
        //添加请求
        addRequestSum(){
            this.requestSum++
        },
        //修改正在请求的状态
        setIsPedding(isPedding){
            this.isPedding=isPedding
        }
    }
})

export default useHttpStore